1. Field
The present invention relates generally to computer software compiler optimization, and more specifically, to optimizing compiler performance by performing object collocation at compile time.
2. Description of the Related Art
In computer software compiler design, optimizations can be applied to enhance various attributes of the resulting compiled code. Optimizations may target reducing execution time and/or memory usage. One type of optimization in object-oriented programs is scalarization, in which an object is “exploded” into its individual fields. After scalarization, the exploded object is no longer considered an object; rather, it is replaced by a local variable for each field of the original object. These local variables can be aggressively optimized, and even eliminated altogether if they are found to be unnecessary. Scalarization of an object may eliminate overhead imposed on that object by the object-oriented programming paradigm.
Scalarization has restrictions, and may not be performed under all circumstances. For example, if a dereference of a pointer variable (i.e., a value pointed to by the pointer variable) can be reached by two different definitions of that pointer, then the dereferencing semantics are retained so that the proper object will be used. This means that fields accessed by such dereferences should reside in memory occupying the same offset to ensure that field load operations can be implemented efficiently and unambiguously. As a second example, if an object reference is used and updated inside of a loop, and is also initialized outside of the loop, then the use in the loop is reached by two definitions, so none of the objects involved can be scalarized. In practice, these restrictions prevent scalarization of such objects.